package cn.jsj.cases.dispose;

import java.io.IOException;
import java.util.Date;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 律师业绩报表查看处理类
 * @author LI
 */
 public class LawyerChartRequest extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
	 public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// 调试信息
		 cn.jsj.utils.SysLogger.PrintInfo("律师业绩报表查询！");

		 //获取报表类型参数
		 int lawyerCatalog=Integer.parseInt(request.getParameter("lawyerChartCatalog").trim());
		 //获取时间段
		 String startTime=request.getParameter("startTime").trim();
		 String endTime=request.getParameter("endTime").trim();

		 //开始结束时间
		 Date startDate;
		 Date endDate;

		//调试信息
		 cn.jsj.utils.SysLogger.PrintInfo("canshu-------->"+startTime+"   "+endTime);
		 //如果用户没有输入时间
		 if(startTime.equalsIgnoreCase("0")||startTime.equalsIgnoreCase("undefined")||startTime.length()==0){
			//调试信息
			 cn.jsj.utils.SysLogger.PrintInfo("没有输入时间");

			 //获取当前年份
			 int year=cn.jsj.utils.TimeDispose.getYear();
			 //构建今年时间段
			 String start=year+"-01-01";
			 String end=year+"-12-31";

			 startDate=cn.jsj.utils.TimeDispose.transferDate(start);
			 endDate=cn.jsj.utils.TimeDispose.transferDate(end);
		 }else{
			 startDate=cn.jsj.utils.TimeDispose.transferDate(startTime);
			 endDate=cn.jsj.utils.TimeDispose.transferDate(endTime);
		 }

		 //新建参数类
		 cn.jsj.bgtodb.LawyerChartProperty lcp=new cn.jsj.bgtodb.LawyerChartProperty();
		 //赋值
		 lcp.setEndTime(endDate);
		 lcp.setStartTime(startDate);
		 lcp.setLawyerCatalog(lawyerCatalog);
		 //调试信息
		 cn.jsj.utils.SysLogger.PrintInfo("获取的参数为---->"+lawyerCatalog);

		 //获取报表信息
		 cn.jsj.dao.TblCaseInfoDAO tcid=new cn.jsj.dao.TblCaseInfoDAO();
		 String arrayString=tcid.getLawyerChartInfo(lcp);

		 //输出流
		 java.io.PrintWriter out=response.getWriter();

		 //输出到客户端
		 out.println(arrayString);
		 out.flush();
		 out.close();
	}
}